import java.util.ArrayList;

/**Class represents a Student.
 * 
 * @author Kurt Micheli
 * @author Gabriel Rauter
 * @author Max Mulatz
 */
public class Student extends Person {

	private String matnr = "";
	private ArrayList<Certificates> certificates = null;
	
	
	/**Creates a Student.
	 * 
	 * @param matnr The matnr of the Stundet. 
	 * @param name name of a Student.
	 * @param surname surname of a Student.
	 */
    public Student(String matnr, String name, String surname) {
		super(name,surname);
		this.matnr = matnr;
		this.certificates = new ArrayList<Certificates>();
	}
	
	/**Returns a Toutor to convert a Stundet to a Tutor.
	 * 
	 * @param id The id of the Tutor.
	 * @return Tutor Tutorobject.
	 */
	public Tutor getTutor(String id) {
		return new Tutor(id, this);
	}
	
	/**Adds a Certificate to the Student.
	 * 
	 * @param certificate A Certidicateobject.
	 */
	public void addCertificate(Certificates certificate) {
		this.certificates.add(certificate);
	}
	
	/**Returns the matnr of the the Student.
	 * 
	 * @return String matnr.
	 */
    public String getMatnr() {
		return this.matnr;
	}
	
	/**Returns all Certificates from a Student.
	 * 
	 * @return Arraylist<Certificates> all Certificates.
	 */
	public ArrayList<Certificates> getCertificates() {
		return this.certificates;
	}
	
	/**Returns all Certificates from a Student.
	 * 
	 * @return String all Certificates well formatted.
	 */	
	public String listCertificates() {
		String temp ="";
		for(int i = 0;i < certificates.size();i++) {
			if(i == certificates.size()-1) {
				temp += certificates.get(i).toString();
			}else {
				temp += certificates.get(i).toString()+'\n';
			}
		}
		return temp;
	}
	
	/**Returns all information from a Student.
	 * 
	 * @return String all informations well formatted.
	 */	
    public String toString() {
		return this.getMatnr() + " " + super.toString();
	}
}
